package com.example.service;


import com.example.mapper.StudentChooseCourseMapper;
import com.example.model.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentChooseCourseService {
    @Autowired
    StudentChooseCourseMapper studentChooseCourseMapper;

    public String studentChooseCourse( String courseId, String student_num){
        System.out.println(courseId+ " " + student_num);
        if(studentChooseCourseMapper.isExitCourse(courseId) != null){
            if(studentChooseCourseMapper.alreadyExit(courseId,student_num)==0){
                studentChooseCourseMapper.studentChooseCourse(courseId, student_num);
                return "success";
            }else {
                return "already exit";
            }
        }else {
            return "is Exit";
        }
    }
    public void studentDeleteCourse(String add_course_num){
        studentChooseCourseMapper.studentDeleteCourse(add_course_num);
    }
//    查询学生加入的所有课程的信息
    public List<Course> selectAllCourse(String number){
       return studentChooseCourseMapper.allCourse(number);
    }
}
